package com.yanliang.blog.service;

import com.yanliang.blog.mapper.ArticleDao;
import com.yanliang.blog.pojo.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

@Service
public class ArticleServie {

    @Autowired
    ArticleDao articleDao;

    public Page<Article> findTArticle(Integer pageNum) {
        if (pageNum == null){
            pageNum = 1;
        }
        Pageable pageable = PageRequest.of(pageNum - 1, 2,Sort.by("id"));
        Page<Article> page = articleDao.findAll(pageable);
        return page;
    }
}
